<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true" :bgColorStyle="theme">
			<block slot="backText">{{$t("返回")}}</block>
			<block slot="content">排序条件</block>
		</cu-custom>
		<form @submit="search" style='display:block;'>
			<view id='main' v-show='TabCur == 0'>
				<js-select labelName='单行文本' :dictData="getOrderData('testInput')" path='orderBy1' :value='main.orderBy1'></js-select>
				<js-select labelName='多行文本' :dictData="getOrderData('testTextarea')" path='orderBy2' :value='main.orderBy2'></js-select>
				<js-select labelName='下拉框' :dictData="getOrderData('testSelect')" path='orderBy3' :value='main.orderBy3'></js-select>
				<js-select labelName='日期时间' :dictData="getOrderData('testDatetime')" path='orderBy4' :value='main.orderBy4'></js-select>
				<js-select labelName='日期选择' :dictData="getOrderData('testDate')" path='orderBy5' :value='main.orderBy5'></js-select>
				<js-select labelName='备注信息' :dictData="getOrderData('remarks')" path='orderBy6' :value='main.orderBy6'></js-select>
			</view>
			<button class="margin-top text-white" :style="{backgroundColor:theme}" form-type="submit">搜索</button>
			<button class="margin-top text-white bg-red" @tap.stop="clear">清空</button>
		</form>
	</view>
</template>
<script>

	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				CustomBar: this.CustomBar,
				TabCur: 0,
				main: {}
			}
		},
		computed: {
			...mapState(["theme"])
		},
		mounted() {
			/* this.get('1358632213327491072'); */
			this.main = {
				testUser:{},
				testOffice:{}
			}
			let _this = this
			uni.getStorage({
			    key: 'list_test_order',
			    success:(res)=> {
			       _this.main = res.data
			    }
			});
		},
		methods: {
			search(e) {
				let formData = e.detail.value
				// console.log(formData)
				uni.setStorage({
				    key: 'list_test_order',
				    data: formData,
				    success: function () {
				       uni.navigateBack({
				       	delta: 1
				       });
				    }
				});
			},
			getOrderData(val){
				let result = []
				result.push({"name":"不排序","value":""})
				result.push({"name":"升序","value": val + " asc"})
				result.push({"name":"降序","value": val + " desc"})
				// console.log(result)
				return result;
			},
			clear(){
				uni.removeStorage({
				    key: 'list_test_order',
				    success: (res)=> {
						uni.navigateBack({
							delta: 1
						});
				    }
				});
			}
		}
	}
</script>
<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
</style>